<template>
  <OrderItem v-for="order in orderList" :key="order.sn" :order="order" />
</template>
  
<script>
import { ORDER_STATUS_TYPE } from '@/utils/constants'
import OrderItem from '@/components/order/OrderItem.vue'
import { ajax } from '@/utils/ajax'
import { OrderApis } from '@/utils/apis'
export default {
  // 订单类型
  props: ['orderType'],
  data() {
    return {
      // 订单列表数据
      orderList: []
    }
  },
  methods: {
    // 获取订单列表
    getOrderList() {
      ajax
        .get(OrderApis.orderListUrl, {
          params: { status: this.orderType }
        })
        .then(({ data }) => {
          console.log('orderList:', data)
          this.orderList = data.objects
        })
    }
  },
  created() {
    // 根据订单类型调用接口
    this.getOrderList()
  },
  components: {
    OrderItem
  }
}
</script>